/*
 * @Author: MiNine
 * @Date: 2020-09-19 09:24:39
 * @LastEditors: MiNine
 * @LastEditTime: 2020-09-27 12:21:04
 * @Description: 
 */
//配置token验证规则

const expressJwt = require("express-jwt");
const {
    TOKEN_KEY
} = require("../utils/const"); //常量的引入

const NO_TOKEN = [
    '/admin/login',
    '/client/registerClient',
    '/client/loginClient',
    '/client/forgetClient',
    '/insureProduct/getItems',
    '/insureProduct/getItem',
    '/insureProduct/getAllItems',
    '/insureSort/getSorts',
]

const jwtAuth = expressJwt({
    secret: TOKEN_KEY, //生成token时使用的密钥
    algorithms: ['HS256'],
    credentialsRequired: false
}).unless({
    //不需要经过token验证
    path: NO_TOKEN
});

module.exports = jwtAuth;